<?php

declare(strict_types=1);

namespace app\controller\admin;

use app\model\admin\CateModel;
use app\model\admin\Pact;
use think\facade\Validate;
use think\Request;

class PactController extends AdminBaseController
{
    // 获取协议
    public function getInfo(Request $request)
    {
        $type = input('type', 1); //默认获取隐私政策
        $info = Pact::where('type', 1)->find();
        return success($info);
    }
    // 设置
    public function setInfo(Request $request)
    {
        $type = input('type', 1); //默认获取隐私政策
        $con = input('con'); //默认获取隐私政策
        $info = Pact::where("type", $type)->find();
        if ($info) {
            $info->con = $con;
            $info->save();
        } else {
            Pact::create([
                "type" => $type,
                "con" => $con,
            ]);
        }
        return success();
    }
}
